#Build the test executable

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

FIND_PACKAGE(Qt4 REQUIRED) # check if QT is available
FIND_PACKAGE(OpenGL)

# GLEW
INCLUDE(cmake/FindGLEW.cmake)
IF(GLEW_FOUND)
	MESSAGE(STATUS "Looking for GLEW - found")
ELSE(GLEW_FOUND)
	MESSAGE(STATUS "Looking for GLEW - not found")
ENDIF(GLEW_FOUND)

SET(QT_USE_QTOPENGL TRUE)

SET(test_SOURCES main.cpp qttestopengl.cpp)
SET(test_HEADERS qttestopengl.h)
SET(test_FORMS qttestopengl.ui)

QT4_WRAP_CPP(test_HEADERS_MOC ${test_HEADERS})
QT4_WRAP_UI(test_FORMS_HEADERS ${test_FORMS})

INCLUDE_DIRECTORIES(
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${GLEW_INCLUDE_PATH}
  $ENV{POUM_LIB_BOOST})

INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})

LINK_DIRECTORIES(
  $ENV{POUM_LIB_GLEW}/lib)

ADD_DEFINITIONS(-DGLEW_STATIC)

ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(renderer)

get_directory_property(output INCLUDE_DIRECTORIES)
message(STATUS ${output})

ADD_EXECUTABLE(
	test
	main.cpp
	${test_SOURCES} 
    ${test_HEADERS_MOC} 
    ${test_FORMS_HEADERS}
	)

#SET(CMAKE_VERBOSE_MAKEFILE 1)
#MESSAGE(${GLEW_LIBRARY})

TARGET_LINK_LIBRARIES(
  test
  opengl_renderer
  renderer
  core
  ${GLEW_LIBRARY}
  ${QT_LIBRARIES}
  ${OPENGL_LIBRARIES}
  )